/**
 * 左旋转字符串
 * Created by JiaJia on 2019/6/10 0010.
 */
public class Code42 {
    public static String leftRotateString(String str,int n) {
        if (str == null || str.length() == 0)
            return str;
        String s1 = reverse(str.substring(0,n));
        String s2 = reverse(str.substring(n,str.length()));
        return reverse(s2)+reverse(s1);
    }
    public static String reverse(String str) {
        StringBuilder sb = new StringBuilder();
        for (int i = str.length() - 1; i >= 0 ; i--) {
            sb.append(str.charAt(i));
        }
        return String.valueOf(sb);
    }

    public static void main(String[] args) {
        String str="abcXYZdef";
        System.out.println(leftRotateString(str,3));
    }
}